package wk.demo.bean;

import android.text.TextUtils;

import org.litepal.crud.LitePalSupport;

/**
 *  浏览历史 ，保存到数据库的。
 */
public class HistoryReadBean extends LitePalSupport {
    private String fileName  ;
    private String filePaht ;
    private long saveTime  ;

    public HistoryReadBean( String filePaht ) {
        this.fileName = getNameOfUrl(filePaht);
        this.filePaht = filePaht;
        this.saveTime = System.currentTimeMillis();
    }

    private String getNameOfUrl(String url) {
        String name = null;
        int pos = url.lastIndexOf('/');
        if (pos >= 0){
            name = url.substring(pos + 1);
        }

        if (TextUtils.isEmpty(name)){
            name = "unKnow";
        }
        return name;
    }

    public String getFileName() {
        return fileName;
    }

    public void setFileName(String fileName) {
        this.fileName = fileName;
    }

    public String getFilePaht() {
        return filePaht;
    }

    public void setFilePaht(String filePaht) {
        this.filePaht = filePaht;
    }

    public long getSaveTime() {
        return saveTime;
    }

    public void setSaveTime(long saveTime) {
        this.saveTime = saveTime;
    }

    @Override
    public String toString() {
        return "HistoryReadBean{" +
                "fileName='" + fileName + '\'' +
                ", filePaht='" + filePaht + '\'' +
                ", saveTime=" + saveTime +
                '}';
    }
}
